package com.gxa.meiye.sso.controller;

import com.gxa.meiye.core.common.JsonResult;
import com.gxa.meiye.sso.service.SMService;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.constraints.Pattern;

@RestController
@RequestMapping("/mlssms")
public class SMController {
    @Autowired
    private SMService smService;
    @RequestMapping("/sendSms")
    @ApiOperation(value = "发送一键登录短信",notes = "发送一键登录短信",httpMethod = "POST")
            public JsonResult sendLoginSms(@Pattern(regexp ="\"^[1](([3][0-9])|([4][5,7,9])|([5][0-9])|([6][6])|\\n\" +\n" +
            "            \"([7][3,5,6,7,8])|([8][0-9])|([9][8,9]))[0-9]{8}$\",message = \"手机号码不正确\"" ,message = "手机号格式问题") @RequestParam("phone") String phone) throws Exception {
            //smsService.sendLoginSms("phone");
            String scode = smService.sendLoginMessage(phone);
        System.out.println(scode);
            JsonResult jsonResult = new JsonResult();
                jsonResult.setCode("1");
                jsonResult.setMsg("发送成功");
                jsonResult.setData(scode);
                return jsonResult;
        }

}
